import 'package:flutter_easyloading/flutter_easyloading.dart';

Future loading(
  Function block, {
  bool isShowLoading = true,
  String? message,
}) async {
  if (isShowLoading) {
    showLoading(message: message ?? '加载中...');
  }
  try {
    await block();
  } catch (e) {
    rethrow;
  } finally {
    dismissLoading();
  }
  return;
}

void showLoading({required String message}) {
  EasyLoading.show(status: message, dismissOnTap: true);
}

void dismissLoading() {
  EasyLoading.dismiss();
}
